package com.ruoyi.consumer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.consumer.domain.CDealError;
import com.ruoyi.consumer.service.ICDealErrorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钱包流水异常Controller
 * 
 * @author ruoyi
 * @date 2023-11-19
 */
@RestController
@RequestMapping("/consumer/dealError")
public class CDealErrorController extends BaseController
{
    @Autowired
    private ICDealErrorService cDealErrorService;

    /**
     * 查询钱包流水异常列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:list')")
    @GetMapping("/list")
    public TableDataInfo list(CDealError cDealError)
    {
        startPage();
        List<CDealError> list = cDealErrorService.selectCDealErrorList(cDealError);
        return getDataTable(list);
    }

    /**
     * 导出钱包流水异常列表
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:export')")
    @Log(title = "钱包流水异常", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CDealError cDealError)
    {
        List<CDealError> list = cDealErrorService.selectCDealErrorList(cDealError);
        ExcelUtil<CDealError> util = new ExcelUtil<CDealError>(CDealError.class);
        util.exportExcel(response, list, "钱包流水异常数据");
    }

    /**
     * 获取钱包流水异常详细信息
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:query')")
    @GetMapping(value = "/{dealErrorId}")
    public AjaxResult getInfo(@PathVariable("dealErrorId") Integer dealErrorId)
    {
        return success(cDealErrorService.selectCDealErrorByDealErrorId(dealErrorId));
    }

    /**
     * 新增钱包流水异常
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:add')")
    @Log(title = "钱包流水异常", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CDealError cDealError)
    {
        return toAjax(cDealErrorService.insertCDealError(cDealError));
    }

    /**
     * 修改钱包流水异常
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:edit')")
    @Log(title = "钱包流水异常", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CDealError cDealError)
    {
        return toAjax(cDealErrorService.updateCDealError(cDealError));
    }

    /**
     * 删除钱包流水异常
     */
    @PreAuthorize("@ss.hasPermi('consumer:dealError:remove')")
    @Log(title = "钱包流水异常", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dealErrorIds}")
    public AjaxResult remove(@PathVariable Integer[] dealErrorIds)
    {
        return toAjax(cDealErrorService.deleteCDealErrorByDealErrorIds(dealErrorIds));
    }
}
